#include <bits/stdc++.h>

using namespace std;

int n, d, k;
const int N = 100010;

bool st[N];
typedef pair<int, int> PII;
PII logs[N];
int cnt[N];

int main()
{
    cin >> n >> d >> k;
    for (int i = 0; i < n; ++i)
    {
        scanf("%d %d", &logs[i].first, &logs[i].second);
    }

    sort(logs, logs + n);

    for (int i = 0, j = 0; i < n; ++i)
    {
        int id = logs[i].second;
        cnt[id]++;
        while (logs[i].first - logs[j].first >= d)
        {
            cnt[logs[j].second]--;
            ++j;
        }
         if (cnt[id] >= k)
         {
            st[id] = true;
         }
    }
    for (int i = 0; i <= 100000; ++i)
    {
        if (st[i])
        {
            printf("%d\n", i);
        }
    }
    return 0;
}